/*
 * @Author: sichuntian sichuntian@smartmappingtek.com
 * @Date: 2024-01-18 11:16:54
 * @LastEditors: sichuntian sichuntian@smartmappingtek.com
 * @LastEditTime: 2024-05-10 14:09:19
 * @Description:
 *
 */
import { join } from "path"
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import { mars3dPlugin } from "vite-plugin-mars3d"
import AutoImport from "unplugin-auto-import/vite"

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      "@": join(__dirname, "src"),
    },
  },
  plugins: [vue(), mars3dPlugin(), AutoImport({ imports: ["vue", "vue-router"] })],
  server: {
    hmr: true, //启动热更新，就是更改了代码自动刷新页面
    port: 8082, //自定义启动时的端口
    open: true, //代表vite项目在启动时自动打开浏览器,
    host: "0.0.0.0",
    proxy: {
      "/api": {
        target: "http://192.168.31.135:8889", // 公司电脑
        // target: "http://192.168.31.85:3001", // 公司电脑-李朝阳
        // target: "http://192.168.1.7:3001", // 个人电脑
        changeOrigin: true, // 允许跨域
        secure: false, //忽略安全证书
        rewrite: (path) => path.replace(/^\/api/, ""), // 重写路径把路径变成空字符,
      },
    },
  },
})
